package com.poker.controller;

import com.poker.entity.UserLog;
import com.poker.service.UserLogService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
@RequestMapping("/userLog")
public class UserLogController extends BaseController{

    @Resource
    private UserLogService userLogService;

    @RequestMapping("/list")
    public String list(Model model, UserLog userLog,
                       @RequestParam(defaultValue = "0") Integer page,
                       @RequestParam(defaultValue = "50") Integer size) {
        Page<UserLog> data = userLogService.findUserLogNoCriteria(page, size);

        model.addAttribute("data", data);
        model.addAttribute("userLog", userLog);
        return managerPage("userLog/list");
    }

    @RequestMapping("/findQuery")
    public String findQuery(Model model , UserLog userLog,
                            @RequestParam(defaultValue = "0") Integer page,
                            @RequestParam(defaultValue = "50") Integer size) {
        Page<UserLog> data = userLogService.findUserLogCriteria(page, size, userLog);

        model.addAttribute("data", data);
        model.addAttribute("userLog", userLog);
        return managerPage("userLog/list");
    }

}
